<div class="grid">
    <div class="col-12">
        <div class="card">
            <div class="card-w-title">
                <h5 style="font-weight: 900">菜单管理</h5>
            </div>
            <p-toolbar>
                <div
                    class="p-toolbar-group-left flex flex-wrap formgroup-inline"
                ></div>

                <div class="p-toolbar-group-right formgroup-inline">
                    <div class="field">
                        <button
                            pButton
                            type="button"
                            label="新增菜单"
                            icon="pi pi-plus"
                            class="mr-2"
                            (click)="openDialog('normal')"
                        ></button>
                    </div>
                </div>
            </p-toolbar>
        </div>
    </div>
    <div class="col-12">
        <div class="card" style="min-height: 625px">
            <p-treeTable [value]="tableData" responsiveLayout="scroll" [rowHover]="true">
                <ng-template pTemplate="header">
                    <tr>
                        <th width="15%">
                            <div
                                class="flex justify-content-between align-items-center"
                            >
                                菜单名称
                            </div>
                        </th>
                        <th width="15%">
                            <div
                                class="flex justify-content-between align-items-center"
                            >
                                菜单描述
                            </div>
                        </th>
                        <th width="15%">
                            <div
                                class="flex justify-content-between align-items-center"
                            >
                                相关链接
                            </div>
                        </th>
                        <th width="15%">
                            <div
                                class="flex justify-content-between align-items-center"
                            >
                                排序编号
                            </div>
                        </th>
                        <th width="40%">
                            <div
                                class="flex justify-content-between align-items-center"
                            >
                                操作
                            </div>
                        </th>
                    </tr>
                </ng-template>
                <ng-template pTemplate="body" let-rowNode let-rowData="rowData">
                    <tr [ttRow]="rowNode">
                        <td>
                            <p-treeTableToggler
                                [rowNode]="rowNode"
                            ></p-treeTableToggler>
                            {{ rowData.frontendMenuName }}
                        </td>
                        <td>{{ rowData.description }}</td>
                        <td>{{ rowData.frontendMenuUrl }}</td>
                        <td>{{ rowData.frontendMenuSort }}</td>
                        <td>
                            <button
                                pButton
                                pRipple
                                icon="pi pi-plus"
                                type="button"
                                label="新增子菜单"
                                style="margin-left: 20px"
                                *ngIf="!rowData.pid"
                                (click)="openDialog('add',rowData)"
                            ></button>
                            <button
                                pButton
                                pRipple
                                type="button"
                                label="编辑"
                                class="p-button-secondary"
                                style="margin-left: 20px"
                                (click)="openDialog('edit',rowData)"
                            ></button>
                            <button
                                pButton
                                pRipple
                                type="button"
                                label="删除"
                                class="p-button-danger"
                                style="margin-left: 20px"
                                (click)="delete(rowData)"
                            ></button>
                        </td>
                    </tr>
                </ng-template>
                <ng-template pTemplate="emptymessage">
                    <tr>
                        <td colspan="7">没有找到统计信息</td>
                    </tr>
                </ng-template>
                <ng-template pTemplate="loadingbody">
                    <tr>
                        <td colspan="7">正在加载统计信息，请稍等</td>
                    </tr>
                </ng-template>
            </p-treeTable>
        </div>
    </div>
</div>
<p-dialog
    [header]="modalTitle"
    [(visible)]="display"
    [modal]="true"
    [style]="{ width: '500px' }"
    [draggable]="false"
    [resizable]="false"
>
    <div class="field grid">
        <label for="" class="col-fixed w-9rem"
            ><span style="color: red">*</span>菜单名称:</label
        >
        <div class="col">
            <input
                type="text"
                pInputText
                [(ngModel)]="form.name"
            />
        </div>
    </div>
    <div class="field grid">
        <label for="" class="col-fixed w-9rem"
            ><span style="color: red">*</span>菜单描述:</label
        >
        <div class="col">
            <input
                type="text"
                pInputText
                [(ngModel)]="form.desc"
            />
        </div>
    </div>
    <div class="field grid">
        <label for="" class="col-fixed w-9rem"
            ><span style="color: red">*</span>相关链接:</label
        >
        <div class="col">
            <input
                type="text"
                pInputText
                [(ngModel)]="form.link"
            />
        </div>
    </div>
    <div class="field grid">
        <label for="" class="col-fixed w-9rem"
            ><span style="color: red">*</span>排序编号:</label
        >
        <div class="col">
            <input
                type="number"
                pInputText
                [(ngModel)]="form.sort"
            />
        </div>
    </div>
    <ng-template pTemplate="footer">
        <p-button
            (click)="submit()"
            label="确认"
            styleClass="p-button-text"
        ></p-button>
        <p-button
            (click)="display = false"
            label="取消"
            styleClass="p-button-text"
        ></p-button>
    </ng-template>
</p-dialog>
<p-confirmDialog [style]="{ width: '500px' }"></p-confirmDialog>
<p-toast></p-toast>